package com.room.search.repository;

import com.room.search.domain.RoomCommunity;
import com.room.search.domain.RoomGoods;
import com.room.search.domain.enumeration.BkRoomTypeEnum;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * Spring Data SQL repository for the RoomCommunity entity.
 */
@SuppressWarnings("unused")
@Repository
public interface RoomCommunityRepository extends JpaRepository<RoomCommunity, Long>, JpaSpecificationExecutor<RoomCommunity> {

    Optional<RoomCommunity> findByName(String name);


    List<RoomCommunity> findAllByProvinceAndCity(String province, String city, Pageable pageable);

//算出城市的区县下的小区数量
    Integer countAllByCityAndDistrict(String city, String district);

    @EntityGraph("community_file")
    Optional<RoomCommunity> findById(Long id);


    List<RoomCommunity> findAllByCityAndDistrictLike(String city, String s);
}
